package __MACOSX;

import static org.junit.Assert.*;



import org.junit.Before;
import org.junit.Test;

public class testrobot {
private static IRobot robot1,robot2;
@Before
public  void setUpBefore() throws Exception {
	long[] temp2 ={3,3};
	long[] temp1 ={0,-1};
	robot1 = new IRobot((long) 2000,temp1,temp2);
}
	@Test
public final void testconstructor3v()throws outofboardexception{
		long[] temp2 ={3,3};
		long[] temp1 ={0,-1};
		IRobot robot = new IRobot((long) 200,temp1,temp2);
		assertEquals(200,robot.getenergy());
		assertEquals(temp1,robot.getrichting());
		assertEquals(temp2,robot.getpositie());
}
	@Test
	public final void testisvalidenergy1() throws outofboardexception{
				assertFalse(robot1.isvalidenergy(-5));
	}
	@Test
	public final void testisvalidenergy2() throws outofboardexception{
				assertFalse(robot1.isvalidenergy(3000000));
	}
	@Test
	public final void testisvalidenergy3() throws outofboardexception{
			assertTrue(robot1.isvalidenergy(100));
	}
	@Test
	public final void testisvalidrichting1(){
		long[] richting ={1,0};	
		assertTrue(IRobot.isvalidrichting(richting));
	}
	@Test
	public final void testisvalidrichting2(){
		long[] richting ={-1,0};	
		assertTrue(IRobot.isvalidrichting(richting));
	}
	@Test
	public final void testisvalidrichting3(){
		long[] richting ={0,-1};	
		assertTrue(IRobot.isvalidrichting(richting));
	}
	@Test
	public final void testisvalidrichting4(){
		long[] richting ={0,1};	
		assertTrue(IRobot.isvalidrichting(richting));
	}
	@Test
	public final void testisvalidrichting5(){
		long[] richting ={7,5};	
		assertFalse(IRobot.isvalidrichting(richting));
	}
	@Test
	public final void testisvalidpositie1(){
		long[] positie ={-1,5};
		assertFalse(robot1.isvalidpositie(positie));
	}
	@Test
	public final void testisvalidpositie2(){
		long[] positie ={5,-3};
		assertFalse(robot1.isvalidpositie(positie));
	}
	@Test
	public final void testisvalidpositie3(){
		long[] positie ={-1,-8};
		assertFalse(robot1.isvalidpositie(positie));
	}
	@Test
	public final void testisvalidpositie4(){
		long[] positie ={5,5};
		assertTrue(robot1.isvalidpositie(positie));
	}
	@Test
	public  final void testemoveforward() throws outofboardexception{
		robot1.emoveforward();
		assertEquals((long) 1500,robot1.getenergy());
		assertEquals((long) 3,robot1.getpositie()[0]);
		assertEquals((long) 2,robot1.getpositie()[1]);
	}
	@Test
	public final void testekwartrechts(){
		robot1.ekwartrechts();
		assertEquals((long) 1900,robot1.getenergy());
		assertEquals(-1,robot1.getrichting()[0]);
		assertEquals(0,robot1.getrichting()[1]);
	}
	@Test
	public final void testekwartlinks(){
		robot1.ekwartlinks();
		assertEquals((long) 1900,robot1.getenergy());
		assertEquals(1,robot1.getrichting()[0]);
		assertEquals(0,robot1.getrichting()[1]);
	}
	@Test
	public final void testManhattan() throws overloadexception{
		long[] test1={0,0};
		long[] test2={8,-9};
		assertEquals((long) 17,IRobot.manhattan(test1, test2));
			}
	@Test
	public final void testManhattan2() throws overloadexception{
		long[] test1={0,0};
		long[] test2={0,0};
		assertEquals((long) 0,IRobot.manhattan(test1, test2));
			}
	@Test
	public final void testisvaldmanhat1() {
		long[] test1={0,0};
		long[] test2={8,-9};
		assertTrue(IRobot.isvalidmanh(test1, test2));
			}
	@Test
	public final void testisvaldmanhat2() {
		long[] test1={Long.MAX_VALUE,0};
		long[] test2={-8,-9};
		assertFalse(IRobot.isvalidmanh(test1, test2));
			}
	@Test
	public final void testisvaldmanhat3() {
		long[] test1={0,Long.MAX_VALUE,};
		long[] test2={-8,-9};
		assertFalse(IRobot.isvalidmanh(test1, test2));
			}
	@Test
	public final void testisvaldmanhat4() {
		long[] test1={Long.MIN_VALUE,0};
		long[] test2={8,9};
		assertFalse(IRobot.isvalidmanh(test1, test2));
			}
	@Test
	public final void testisvaldmanhat5() {
		long[] test1={0,Long.MIN_VALUE};
		long[] test2={8,9};
		assertFalse(IRobot.isvalidmanh(test1, test2));
			}
	@Test
	public final void testzoekenergie1() throws overloadexception {
		long[] test1={3,-7};
		assertEquals(5000,robot1.zoekenergievoorpositie(test1));
			}
	@Test
	public final void testzoekenergie2() throws overloadexception {
		long[] test1={-7,-7};
		assertEquals(10100,robot1.zoekenergievoorpositie(test1));
			}
	@Test
	public final void testzoekenergie3() throws overloadexception {
		long[] test1={3,13};
		assertEquals(5200,robot1.zoekenergievoorpositie(test1));
			}
	@Test
	public final void testzoekenergie4() throws overloadexception {
		long[] test1={13,3};
		assertEquals(5100,robot1.zoekenergievoorpositie(test1));
			}
	@Test
	public final void testzoekenergie5() throws overloadexception {
		long[] test1={-7,3};
		assertEquals(5100,robot1.zoekenergievoorpositie(test1));
			}
	@Test
	public final void testzoekenergie6() throws overloadexception {
		assertEquals(0,robot1.zoekenergievoorpositie(robot1.getpositie()));
			}
	@Test
	public final void testrobotsbij1() throws overloadexception, outofboardexception {
		long [] temp1={0,1};
		long [] temp2={0,0};
		long [] temp3={0,-1};
		long [] temp4={4,4};
		long [] test1={0,3};
		long [] test2={0,4};
		robot1 = new IRobot((long) 20000,temp1,temp2);
		robot2 = new IRobot((long) 20000,temp3,temp4);
		IRobot robot3 = new IRobot((long) 20000,temp1,temp2);
		IRobot robot4 = new IRobot((long) 20000,temp3,temp4);
		IRobot.tweerobotsbijelkaar(robot1, robot2);
		assertEquals(40000-robot1.getenergy()-robot2.getenergy(),robot3.zoekenergievoorpositie(test1)+robot4.zoekenergievoorpositie(test2));
			}
	@Test
	public final void testrobotsbij2() throws overloadexception, outofboardexception {
		long [] temp1={0,1};
		long [] temp2={0,0};
		long [] temp3={0,-1};
		long [] temp4={5,5};
		robot1 = new IRobot((long) 0,temp1,temp2);
		robot2 = new IRobot((long) 0,temp3,temp4);
		IRobot robot3 = new IRobot((long) 0,temp1,temp2);
		IRobot robot4 = new IRobot((long) 0,temp3,temp4);
		IRobot.tweerobotsbijelkaar(robot1, robot2);
		assertEquals(robot1.getpositie(),robot3.getpositie());
		assertEquals(robot1.getenergy(),robot3.getenergy());
		assertEquals(robot1.getrichting(),robot3.getrichting());
		assertEquals(robot2.getpositie(),robot4.getpositie());
		assertEquals(robot2.getenergy(),robot4.getenergy());
		assertEquals(robot2.getrichting(),robot4.getrichting());
			}
	@Test
	public final void testrobotsbij3() throws overloadexception, outofboardexception {
		long [] temp1={0,1};
		long [] temp2={4,5};
		long [] temp3={0,-1};
		long [] temp4={5,5};
		robot1 = new IRobot((long) 20000,temp1,temp2);
		robot2 = new IRobot((long) 20000,temp3,temp4);
		IRobot robot3 = new IRobot((long) 20000,temp1,temp2);
		IRobot robot4 = new IRobot((long) 20000,temp3,temp4);
		IRobot.tweerobotsbijelkaar(robot1, robot2);
		assertEquals(robot1.getpositie(),robot3.getpositie());
		assertEquals(robot1.getenergy(),robot3.getenergy());
		assertEquals(robot1.getrichting(),robot3.getrichting());
		assertEquals(robot2.getpositie(),robot4.getpositie());
		assertEquals(robot2.getenergy(),robot4.getenergy());
		assertEquals(robot2.getrichting(),robot4.getrichting());
			}
	@Test
	public final void testrobotsbij4() throws overloadexception, outofboardexception {
		long [] temp1={0,1};
		long [] temp2={0,0};
		long [] temp3={0,-1};
		long [] temp4={5,5};
		long[] test1 ={0,2};
		long[] test2 ={0,1};
		long[] test3 ={5,3};
		long[] test4 ={0,-1};
		robot1 = new IRobot((long) 1100,temp1,temp2);
		robot2 = new IRobot((long) 1100,temp3,temp4);
		IRobot.tweerobotsbijelkaar(robot1, robot2);
		assertEquals(robot1.getpositie()[0],test1[0]);
		assertEquals(robot1.getpositie()[1],test1[1]);
		assertEquals(robot1.getenergy(),100);
		assertEquals(robot1.getrichting()[0],test2[0]);
		assertEquals(robot1.getrichting()[1],test2[1]);
		assertEquals(robot2.getpositie()[0],test3[0]);
		assertEquals(robot2.getpositie()[1],test3[1]);
		assertEquals(robot2.getenergy(),100);
		assertEquals(robot2.getrichting()[0],test4[0]);
		assertEquals(robot2.getrichting()[1],test4[1]);
			}
}
